﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using MyStyle.Model;
using MyStyle.RepositoryLayer;
using MyStyle.Service;
using System.Collections;
using System.Collections.Generic;

namespace MyStyle.Controller
{
    [ApiController]
    [Route("/Customer")]
    public class CustomerController : ControllerBase
    {
        /// <summary>
        /// 
        /// </summary>
        /// 

        private readonly ICustomerService _customerService;

        private readonly ILogger<CustomerController> _logger;

        public CustomerController(ICustomerService customerService)
        {
            _customerService = customerService;
        }

        public string Index()
        {
            return "abc customer";
        }

        //[HttpGet(nameof(GetCustomer))]
        [HttpGet("index")]
        public IActionResult GetCustomer(int id)
        {
            var result = _customerService.GetCustomer(id);
            if (result != null)
            {
                return Ok(result);
            }
            return BadRequest("No records found");
        }
        [HttpGet("GetAllCustomer")]
        public IActionResult GetAllCustomer()
        {
            var result = _customerService.GetAllCustomers();
            if (result != null)
            {
                return Ok(result);
            }
            return BadRequest("No records found");
        }
        [HttpPost(nameof(InsertCustomer))]
        public IActionResult InsertCustomer(Customer customer)
        {
            _customerService.InsertCustomer(customer);
            return Ok("Data inserted");
        }
        [HttpPut(nameof(UpdateCustomer))]
        public IActionResult UpdateCustomer(Customer customer)
        {
            _customerService.UpdateCustomer(customer);
            return Ok("Updation done");
        }
        [HttpDelete(nameof(DeleteCustomer))]
        public IActionResult DeleteCustomer(int Id)
        {
            _customerService.DeleteCustomer(Id);
            return Ok("Data Deleted");
        }

        [HttpGet("test")]
        public object test()
        {
            return _customerService.GetRe();
        }

    }
}
